local congjianx = fk.CreateSkill {
    name = "jinld__congjianx",
}

Fk:loadTranslationTable {
    ["jinld__congjianx"] = "从鉴",
    [":jinld__congjianx"] = "当你受到伤害后，若伤害来源的体力值不小于你，你可以令其视为使用一张【调虎离山】（目标须包含你）。",

    ["#jinld__congjianx-choose"] = "从鉴：选择一名其他角色成为【调虎离山】的另一个目标",

    ["$jinld__congjianx1"] = "为人臣属，安可不随？",
    ["$jinld__congjianx2"] = "主公有难，吾当从之。",
}

congjianx:addEffect(fk.Damaged, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(congjianx.name) and not data.from.dead and
        not data.from:prohibitUse(Fk:cloneCard("lure_tiger")) and data.from.hp >= player.hp
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        if player.dead or data.from.dead then return end
        local targets = table.filter(room:getOtherPlayers(data.from),
            function(p) return data.from:canUseTo(Fk:cloneCard("lure_tiger"), p) end)
        if #targets == 0 then
            room:useVirtualCard("lure_tiger", nil, data.from, player, congjianx.name, true)
        else
            local to = room:askToChoosePlayers(data.from, {
                min_num = 1,
                max_num = 1,
                targets = targets,
                skill_name = congjianx.name,
                prompt = "#jinld__congjianx-choose",
                cancelable = true,
            })
            table.insertIfNeed(to, player)
            room:useVirtualCard("lure_tiger", nil, data.from, to, congjianx.name, true)
        end
    end,
})

return congjianx
